package com.bstek.urule.console;

import com.bstek.urule.RuleException;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.io.InputStream;

/**
 * @autor gehongbin
 * @date 4/27/22
 **/
public class XmlUtils {

    public static Element parseXml(InputStream stream) {
        SAXReader reader = new SAXReader();
        Document document;
        try {
            document = reader.read(stream);
            Element root = document.getRootElement();
            return root;
        } catch (DocumentException e) {
            throw new RuleException(e);
        }
    }
}
